'''
Created on 28/03/2010

@author: miguel
'''
import pygame
from pygame.sprite import Sprite
from vec2d import vec2d

class BugExit(Sprite):
    (USER, COMPUTER) = range(2)
    BUGEXIT_IMAGE = './data/bugexit.png'

    def __init__(self, screen, game, field, user_computer):
        Sprite.__init__(self)

        self.screen = screen
        self.game = game
        self.field = field
        if user_computer == self.USER:
            self.pos = vec2d(240,510)
            self.image = pygame.image.load(self.BUGEXIT_IMAGE)
            ''' take the part of the board for the user home'''
            for i in range(3):
                x = 240 + (30 * i)
                for j in range(3):
                    y = 510 + (30 * j)
                    self.game.game_board.take_position(vec2d(x, y), self.game.game_board.USER_HOME)

        elif user_computer == self.COMPUTER:
            self.pos = vec2d(240,0)
            self.image = pygame.image.load(self.BUGEXIT_IMAGE)
            self.image = pygame.transform.flip(self.image, False, True)
            ''' take the part of the board for the user home'''
            for i in range(3):
                x = 240 + (30 * i)
                for j in range(3):
                    y = 0 + (30 * j)
                    self.game.game_board.take_position(vec2d(x, y), self.game.game_board.COM_HOME)

        self.rect = self.image.get_rect().move(self.pos)

    def update(self):
        pass

    def draw(self):
        self.screen.blit(self.image, self.rect)